<?php
/**
 * Zend Framework
 *
 * LICENSE
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://framework.zend.com/license/new-bsd
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@zend.com so we can send you a copy immediately.
 *
 * @category   Zend
 * @package    Zend_Controller
 * @subpackage Zend_Controller_Action_Helper
 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 * @version    $Id: Url.php 20096 2010-01-06 02:05:09Z bkarwin $
 */

/**
 * @see Zend_Controller_Action_Helper_Abstract
 */
require_once 'Zend/Controller/Action/Helper/Abstract.php';

/**
 * Helper Осуществляет проверку на авторизованного пользователя
 *
 * @uses       Zend_Controller_Action_Helper_Abstract
 * @category   Gb
 * @package    Gb_Controller
 * @subpackage Zend_Controller_Action_Helper
 * @copyright  Copyright (c) Userator
 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 */
class Gb_Controller_Action_Helper_UserAuth extends Zend_Controller_Action_Helper_Abstract {
	/**
	 * Осуществляет проверку на авторизованного пользователя
	 *
	 * Если пользователь авторизован и не является гостем то возвращает true,
	 * если иначе то false
	 */
	public function has() {
		$auth = Zend_Auth::getInstance();
		$defUser = new Zend_Config_Ini(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'configs/userDefault.ini', APPLICATION_ENV);
		// Если пользователь авторизован и не является гостем
		if ($auth->hasIdentity() and $auth->getIdentity()->login != $defUser->get('login')) {
			return true;
		}

		return false;
	}

}
